package main

import (
	"fmt"
	"net"
	"sync"
	"time"
)

var wg sync.WaitGroup

func main() {
	start := time.Now()

	for i := 21; i < 120; i++ {
		wg.Add(1)
		go func(j int) {
			defer wg.Done()
			address := fmt.Sprintf("10.37.8.67:%d", j)
			conn, err := net.Dial("Tcp", address)
			if err != nil {
				fmt.Printf("%s关闭了\n", address)
				return
			}
			defer conn.Close()
			fmt.Printf("%s 打开了\n", address)
		}(i)
	}
	wg.Wait()

	elapsed := time.Since(start) / 1e8
	fmt.Printf("\n\n %d s", elapsed)
}
